package org.mspring.mlog.entity.bbs;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 版块
 * 
 * @author Gao Youbo
 * @since 2013年8月6日
 */
@Entity
@Table(name = "forum")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Forum implements Serializable {
    private static final long serialVersionUID = 6970155164224053508L;

    private Long id;
    private String name;
    private String description;
    private Integer order;
    private ForumCatalog catalog;

    private Long topics; // 主题数
    private Long replys; // 回帖数

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "name", length = 30, nullable = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "description", length = 300, nullable = true)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "order", nullable = true)
    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = ForumCatalog.class)
    @JoinColumn(name = "forum_catalog", nullable = false)
    public ForumCatalog getCatalog() {
        return catalog;
    }

    public void setCatalog(ForumCatalog catalog) {
        this.catalog = catalog;
    }

    
    @Column(name = "topics")
    public Long getTopics() {
        return topics;
    }

    public void setTopics(Long topics) {
        this.topics = topics;
    }

    @Column(name = "replys")
    public Long getReplys() {
        return replys;
    }

    public void setReplys(Long replys) {
        this.replys = replys;
    }

}
